From: Claudio Cambra Date: Wed, 22 Mar 2023 14:26:18 +0000 (+0100) Subject: Replace use of raw pointer in wantsAccountSaved signal with AccountPtr X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2^2~26^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=761d03576603b076c99693be80ff6e9b6cf91d00;p=nextcloud-desktop.git Replace use of raw pointer in wantsAccountSaved signal with AccountPtr Signed-off-by: Claudio Cambra --- diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index f89085664..1ff8dc4fb 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -280,7 +280,7 @@ void AccountManager::save(bool saveCredentials) settings->setValue(QLatin1String(versionC), maxAccountsVersion); for (const auto &acc : std::as_const(_accounts)) { settings->beginGroup(acc->account()->id()); - saveAccountHelper(acc->account().data(), *settings, saveCredentials); + saveAccountHelper(acc->account(), *settings, saveCredentials); settings->endGroup(); } @@ -288,7 +288,7 @@ void AccountManager::save(bool saveCredentials) qCInfo(lcAccountManager) << "Saved all account settings, status:" << settings->status(); } -void AccountManager::saveAccount(Account *newAccountData) +void AccountManager::saveAccount(const AccountPtr &newAccountData) { qCDebug(lcAccountManager) << "Saving account" << newAccountData->url().toString(); const auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC)); @@ -311,7 +311,7 @@ void AccountManager::saveAccountState(AccountState *a) qCDebug(lcAccountManager) << "Saved account state settings, status:" << settings->status(); } -void AccountManager::saveAccountHelper(Account *account, QSettings &settings, bool saveCredentials) +void AccountManager::saveAccountHelper(const AccountPtr &account, QSettings &settings, bool saveCredentials) { qCDebug(lcAccountManager) << "Saving settings to" << settings.fileName(); settings.setValue(QLatin1String(versionC), maxAccountVersion); diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h index ceb357f09..cc405fec1 100644 --- a/src/gui/accountmanager.h +++ b/src/gui/accountmanager.h @@ -92,7 +92,7 @@ public: public slots: /// Saves account data when adding user, when updating e.g. dav user, not including the credentials - void saveAccount(OCC::Account *newAccountData); + void saveAccount(const OCC::AccountPtr &newAccountData); /// Saves account state data, not including the account void saveAccountState(OCC::AccountState *a); @@ -118,7 +118,7 @@ signals: private: // saving and loading Account to settings - void saveAccountHelper(Account *account, QSettings &settings, bool saveCredentials = true); + void saveAccountHelper(const AccountPtr &account, QSettings &settings, bool saveCredentials = true); AccountPtr loadAccountHelper(QSettings &settings); bool restoreFromLegacySettings(); diff --git a/src/gui/connectionvalidator.cpp b/src/gui/connectionvalidator.cpp index 61ba6ee44..6c1bec008 100644 --- a/src/gui/connectionvalidator.cpp +++ b/src/gui/connectionvalidator.cpp @@ -138,7 +138,7 @@ void ConnectionValidator::slotStatusFound(const QUrl &url, const QJsonObject &in if (_account->url() != url) { qCInfo(lcConnectionValidator()) << "status.php was redirected to" << url.toString(); _account->setUrl(url); - emit _account->wantsAccountSaved(_account.data()); + emit _account->wantsAccountSaved(_account); } if (!serverVersion.isEmpty() && !setAndCheckServerVersion(serverVersion)) { diff --git a/src/gui/creds/webflowcredentials.cpp b/src/gui/creds/webflowcredentials.cpp index bd2eb458e..d56183072 100644 --- a/src/gui/creds/webflowcredentials.cpp +++ b/src/gui/creds/webflowcredentials.cpp @@ -218,7 +218,7 @@ void WebFlowCredentials::persist() { } _account->setCredentialSetting(userC, _user); - emit _account->wantsAccountSaved(_account); + emit _account->wantsAccountSaved(_account->sharedFromThis()); // write cert if there is one if (!_clientSslCertificate.isNull()) { diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 5acb7897b..e01fdbe0e 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -146,7 +146,7 @@ void Account::setDavUser(const QString &newDavUser) _davUser = newDavUser; - emit wantsAccountSaved(this); + emit wantsAccountSaved(sharedFromThis()); emit prettyNameChanged(); } @@ -609,7 +609,7 @@ void Account::slotHandleSslErrors(QNetworkReply *reply, QList errors) if (!approvedCerts.isEmpty()) { QSslConfiguration::defaultConfiguration().addCaCertificates(approvedCerts); addApprovedCerts(approvedCerts); - emit wantsAccountSaved(this); + emit wantsAccountSaved(sharedFromThis()); // all ssl certs are known and accepted. We can ignore the problems right away. qCInfo(lcAccount) << out << "Certs are known and trusted! This is not an actual error."; @@ -737,7 +737,7 @@ bool Account::shouldSkipE2eeMetadataChecksumValidation() const void Account::resetShouldSkipE2eeMetadataChecksumValidation() { _skipE2eeMetadataChecksumValidation = false; - emit wantsAccountSaved(this); + emit wantsAccountSaved(sharedFromThis()); } int Account::serverVersionInt() const @@ -1122,7 +1122,7 @@ void Account::setEncryptionCertificateFingerprint(const QByteArray &fingerprint) _encryptionCertificateFingerprint = fingerprint; _e2e.usbTokenInformation()->setSha256Fingerprint(fingerprint); Q_EMIT encryptionCertificateFingerprintChanged(); - Q_EMIT wantsAccountSaved(this); + Q_EMIT wantsAccountSaved(sharedFromThis()); } void Account::setAskUserForMnemonic(const bool ask) diff --git a/src/libsync/account.h b/src/libsync/account.h index 5e6c67318..19c0a1124 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -444,7 +444,7 @@ signals: void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *); // e.g. when the approved SSL certificates changed - void wantsAccountSaved(OCC::Account *acc); + void wantsAccountSaved(const OCC::AccountPtr &acc); void wantsFoldersSynced(); diff --git a/src/libsync/creds/httpcredentials.cpp b/src/libsync/creds/httpcredentials.cpp index ef1c4c5e8..2480cb923 100644 --- a/src/libsync/creds/httpcredentials.cpp +++ b/src/libsync/creds/httpcredentials.cpp @@ -434,7 +434,7 @@ void HttpCredentials::persist() // it's just written if it gets passed into the constructor. _account->setCredentialSetting(QLatin1String(clientCertBundleC), _clientCertBundle); } - emit _account->wantsAccountSaved(_account); + emit _account->wantsAccountSaved(_account->sharedFromThis()); // write secrets to the keychain if (!_clientCertBundle.isEmpty()) {